package com.yjt.termworks;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

public class ServiceActivity extends AppCompatActivity {
    private RecyclerView mRecyclerview;
    private HomeAdapter mAdapter;
    private String[] names={"班主任","数学老师","英语老师","家长"};
    private int[] icons={R.drawable.avatar,R.drawable.avatar,R.drawable.avatar,R.drawable.avatar};
    private String[] introduces={
            "法撒旦撒阿德飒飒",
            "dasdasdas dasd",
            "sadfsafdwqeasd",
            "sadasdasdasdasd"
    };

    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);

    }

    class HomeAdapter extends RecyclerView.Adapter<HomeAdapter.MyViewHolder> {
        @NonNull
        @Override
        public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
            MyViewHolder holder =new MyViewHolder(LayoutInflater.from(ServiceActivity.this).inflate(R.layout.recycler_item,parent,false));

            return holder;
        }

        @Override
        public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
            holder.name.setText(names[position]);
            holder.touxiang.setImageResource(icons[position]);
            holder.introduce.setText(introduces[position]);
        }

        @Override
        public int getItemCount() {
            return names.length;
        }
        class MyViewHolder extends RecyclerView.ViewHolder{
            TextView name;
            ImageView touxiang;
            TextView introduce;
            public MyViewHolder(View view){
                super(view);
                name=view.findViewById(R.id.name);
                touxiang=view.findViewById(R.id.touxiang);
                introduce=view.findViewById(R.id.introduce);
            }
        }
    }
}
